<template>
  <el-dialog width="500px" append-to-body title="发送短信通知" :visible.sync="dialogVisible" :close-on-click-modal="false">
    <el-form ref="ruleForm" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="金额" prop="setmeal_foregift">
        <el-input v-model="form.setmeal_foregift" placeholder="请输入市场价格" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" @click="dialogVisible = false">取 消</el-button>
      <el-button size="small" type="primary" @click="submit">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { sendOverdueUser } from '@/api/finance'
export default {
  // props: ['orderId', 'whichPeriod'],
  props: {
    orderId: {
      type: String,
      default: ''
    },
    sendItem:{
      type:Object,
      default:()=>({})
    }
  },
  data() {
    return {
      form: {
        setmeal_foregift: ''
      },
      rules: {
        setmeal_foregift: [
          { required: true, message: '金额不能为空', trigger: 'blur' }
        ]
      },
      dialogVisible: false
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        for (const key in this.form) {
          if (key === 'setmeal_foregift') {
            this.form[key] = this.sendItem.setmeal_foregift
          }
        }
      }
    }
  },
  methods: {
    submit() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          const params = { order_id: this.orderId, setmeal_foregift: this.form.setmeal_foregift }
          console.log(this.orderId);
          console.log(this.form.buyout_money);
          sendOverdueUser(params).then(res => {
          this.$message({
            message: '发送成功！',
            type: 'success',
            duration:2000
          })
            this.dialogVisible = false
            this.$emit('getList')
          })
        } else {
          this.$message({
            message: '请检查表单错误',
            type: 'error'
          })
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
